import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  // 变量存储库
  state: {
    // 存储token
    Authorization: localStorage.getItem('Authorization') ? localStorage.getItem('Authorization') : '',
    // 资源权限
    WechatChanelAcl: localStorage.getItem('WechatChanelAcl') ? localStorage.getItem('WechatChanelAcl') : ''
  },
  mutations: {
    // 异步存储
    changeLogin (state, data) {
      console.log('异步存储：', data.Authorization);
      state.Authorization = data.Authorization
      localStorage.setItem('Authorization', data.Authorization)
    },
    // 保存用户资源权限
    saveWechatChanelAcl (state, data) {
      localStorage.setItem(state, data.sysPermission)
      state.WechatChanelAcl = data.sysPermission
    }
  }
})
